home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindlink.net!news
- From: genew@mindlink.bc.ca (Gene Wirchenko)
- Newsgroups: comp.lang.c
- Subject: Re: division problem
- Date: Thu, 01 Feb 1996 03:20:34 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <4epbla$e37@fountain.mindlink.net>
- References: <31097D77.11AA@rain.org> <26JAN199622082450@erich.triumf.ca> <4eh246$u6h@airdmhor.gen.nz> <4ej4ha$66@fountain.mindlink.net> <DLzvGG.2rn@uns.bris.ac.uk> <4emuba$1mo@fountain.mindlink.net> <823118692snz@genesis.demon.co.uk>
- NNTP-Posting-Host: line314.nwm.mindlink.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
-
- >In article <4emuba$1mo@fountain.mindlink.net>
- > genew@mindlink.bc.ca "Gene Wirchenko" writes:
-
- >>>Still no need to use floating point,
- >>>celcius = ((fahrenheit - 32) * 5 + 4) / 9
- >>
- >> Let's assume that you had never run across fahrenheit to celsius
- >>conversion before (because the above could just as easily be a case of
- >>converting flibbles to meeblesnauzers).
- >>
- >> Can you derive the ORIGINAL formula for conversion of F to C?
- >>
- >> If yes, how? Because you don't know what the 4 is for.
-
- >Maybe not but its effect is clearly one of rounding. Perhaps it would be
- >clearer to specify it as (9/2), perhaps not.
-
- Apparently not clearly. For all you/I/etc. know, the 4 might be
- part of the original formula.
-
- >> If no, then it's unclear code, isn't it?
-
- >How would you express it more clearly?
-
- It seems it begs for a comment. This may seem like nitpicking,
- but comments are part of a program.
-
- /* Convert degrees Fahrenheit to degrees Celsius using formula:
- * (F-32)*5/9. The purpose of the added 4 below is for rounding
- * to the nearest degree.
- */
-
- celsius= ...
-
- This is a case where the code isn't obvious, right? (Assuming
- that the formula isn't a common one.)
-
- Not being a Macho Programmer (If it was hard to program, it
- should be hard to read, etc.), I like a well-placed comment.
-
- >--
- >-----------------------------------------
- >Lawrence Kirby | fred@genesis.demon.co.uk
- >Wilts, England | 70734.126@compuserve.com
- >-----------------------------------------
-
- Sincerely,
-
- Gene Wirchenko
-
- C Pronunciation Guide:
- y=x++; "wye equals ex plus plus semicolon"
- x=x++; "ex equals ex doublecross semicolon"
-
-